package factory.one.pojo.common;

import java.util.List;

/**
 * @author sk.z
 * 2023/7/6
 * 分页
 **/
public class Page<T> {

    private List<T> list;
    private final int total;
    private final int size;
    private final int curPage;

    private int firstPage;
    private int lastPage;
    private int prePage;
    private int nextPage;

    public Page(List<T> list, int total, int curPage, int size) {
        this.list = list;
        this.total = total;
        this.curPage = curPage;
        this.size = size;

        this.lastPage = (total - 1) / size + 1;
        this.firstPage = 1;
        this.prePage = curPage - 1;
        this.nextPage = (curPage + 1 > lastPage) ? 0 : curPage + 1;
    }

    public List<T> getList() {
        return list;
    }

    public void setList(List<T> list) {
        this.list = list;
    }

    public int getTotal() {
        return total;
    }

    public int getSize() {
        return size;
    }

    public int getCurPage() {
        return curPage;
    }

    public int getFirstPage() {
        return firstPage;
    }

    public void setFirstPage(int firstPage) {
        this.firstPage = firstPage;
    }

    public int getLastPage() {
        return lastPage;
    }

    public void setLastPage(int lastPage) {
        this.lastPage = lastPage;
    }

    public int getPrePage() {
        return prePage;
    }

    public void setPrePage(int prePage) {
        this.prePage = prePage;
    }

    public int getNextPage() {
        return nextPage;
    }

    public void setNextPage(int nextPage) {
        this.nextPage = nextPage;
    }
}
